#include <stdio.h>


//fixme: support "Yes" "No" ...
int messagebox(char *message)
{
	int choose;

	do
	{
		int input_c = 0, pos = 1;

		printf("\r\033[2K");
		printf("%s(y / n): ", message);
		while (input_c != '\n' && input_c != '\r')
		{
			input_c = raw_getchar();

			if (pos > 1 && (input_c == 0x7f || input_c == 0x08))
			{
				putchar('\b');
				putchar(' ');
				putchar('\b');
				--pos;
			}
			if (input_c >= 0x20 && input_c < 0x7f)
			{
				if (pos == 1)
					choose = input_c;
				++pos;
				putchar(input_c);
			}
			else
			{
				continue;
			}
		}
		if (pos != 2)
			choose = 0;

	} while('Y' != choose && 'y' != choose && 'N' != choose && 'n' != choose);

	printf("\n");
	if ('y' == choose || 'Y' == choose)
	{
		return 1;
	}

	return 0;
}

#if 0
UINT32 CheckSum(void *pBuff, ULONG len)
{
	UINT32 *p, uChkSum;
	ULONG i;

	p = (UINT32 *)pBuff;
	uChkSum = 0;

	for (i = 0; i < len; i += 4, p++)
		uChkSum ^= *p;

	return uChkSum;
}
#endif

